import java.util.Arrays;

public class LeetCode283 {

    public static void main(String[] args) {
        int[] nums = {0, 1, 0, 3, 12};

        moveZeroes(nums);
    }

    public static void moveZeroes(int[] nums) {
        if (nums == null) {
            return;
        }
        // 两个指针 i 和 j
        int j = 0;
        for (int i = 0; i < nums.length; i++) {
            // 当前元素 != 0，就把其交换到左边，等于 0 的交换到右边
            if (nums[i] != 0) {
                int temp = nums[i];
                nums[i] = nums[j];
                nums[j++] = temp;
            }
        }
    }

}
